<template>
    <div>
        <div class="operarea">
            <div class="seach">
                <el-select v-model="seachForm.activStatus" :placeholder="$t('status')" clearable size="mini">
                    <el-option :label="$t('notopened')" :value="0"></el-option>
                    <el-option :label="$t('progresses')" :value="1"></el-option>
                    <el-option :label="$t('over')" :value="2"></el-option>
                </el-select>
                <el-button size="mini" icon="el-icon-search" @click="getData"></el-button>
            </div>
            <div class="btnList">
                <el-button size="mini" @click="showAddDlog">{{$t('add')}}</el-button>
            </div>
        </div>
        <el-card class="cardBox">
            <el-table style="width: 100%" :data="festivalTab" stripe v-adaptive="{bottomOffset: 85}" height="100">
                <el-table-column prop="type" label="活动类型">
                </el-table-column>
                <el-table-column prop="name" label="活动名称">
                </el-table-column>
                <el-table-column prop="time" label="banner图">
                    <template v-slot="scope">
                        <el-image v-if="scope.row.bannerUrl !== '' && scope.row.bannerUrl !== null" :src="scope.row.bannerUrl" class="feelImg" :preview-src-list="getSrcList(scope.$index)"></el-image>
                    </template>
                </el-table-column>
                <el-table-column prop="activStatus" label="活动状态">
                    <template v-slot="scope">
                        <el-tag :type="scope.row.activStatus === '进行中' ? 'success' : 'danger'" :effect="scope.row.activStatus === '进行中' ? 'dark' : 'plain'" @click="editState(scope.row)" size="mini">
                            {{ scope.row.activStatus }}
                        </el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="product" label="活动时间">
                    <template v-slot="scope">
                        {{scope.row.startTime + ' ~ ' + scope.row.endTime}}
                    </template>
                </el-table-column>
                <el-table-column prop="address" label="操作" width="150" fixed="right">
                    <template v-slot="scope">
                        <span v-if="scope.row.status !== $t('over')">
                            <el-button size="mini" @click="showModify(scope.row)">修改</el-button>
                            <el-button size="mini" @click="showDel(scope.row.id)">删除</el-button>
                        </span>
                        <!-- <el-button @click="modify(scope.row.id)" size="mini">{{$t('modify')}}</el-button>
                        <el-button @click="delFest(scope.row.id)" size="mini">{{$t('delete')}}</el-button> -->
                    </template>
                </el-table-column>
            </el-table>
            <el-pagination
                small
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                :pager-count="11"
                :current-page.sync="seachForm.pageNo"
                :page-sizes="[10, 20, 30, 40]"
                :page-size="seachForm.pageSize"
                layout="sizes, prev, pager, next"
                :total="total">
            </el-pagination>
        </el-card>
        <!-- 活动开启 -->
        <el-dialog :title="$t('hint')" :visible.sync="openDialogVisible" width="420px" class="smallDlog" @close="activityDlogClose">
            <span>{{$t('whetostatheact')}}</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="openDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="activityOpen">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <!-- 活动关闭 -->
        <el-dialog :title="$t('hint')" :visible.sync="closeDialogVisible" width="420px" class="smallDlog" @close="activityDlogClose">
            <span>{{$t('whetoendtheact')}}</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="closeDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="activityClose">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <!-- 添加 -->
        <el-dialog :title="$t('add')" :visible.sync="addDialogVisible" width="600px" class="addNFRobeDlog" :close-on-click-modal="false" @close="addDlogClose(addDataForm)">
            <el-form :model="addDataForm" :rules="addRules" :ref="addDataForm" class="motuoForm">
                <el-form-item label="活动类型" label-width="80px" prop="type">
                    <el-select v-model="addDataForm.type" clearable :placeholder="$t('plssel')">
                        <el-option label="促销" :value="0"></el-option>
                        <el-option label="预售" :value="1"></el-option>
                        <el-option label="其他" :value="2"></el-option>
                    </el-select>
                </el-form-item>
                <el-form-item :label="$t('activityname')" label-width="80px" prop="name">
                    <el-input v-model="addDataForm.name" autocomplete="off" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
                <el-form-item label="活动时间" label-width="80px" prop="activityTime">
                    <el-date-picker v-model="addDataForm.activityTime" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions"></el-date-picker>
                </el-form-item>
                <el-form-item label="banner图" label-width="80px" prop="activityTime">
                    <el-upload class="upload-demo" action="/sys/image/uploadImage" :on-success="handleBannerImgUrl" :on-remove="hadleBannerRemove" :file-list="fileBannerList" list-type="picture" :limit="1" :on-exceed="scotland" ref="bannerStripk">
                        <el-button size="small" type="primary">点击上传</el-button>
                    </el-upload>
                </el-form-item>
                <el-form-item label="内容图片" label-width="80px" prop="activityTime">
                    <el-upload class="upload-demo" action="/sys/image/uploadImage" :on-success="handleContentImgUrl" :on-remove="hadleContentRemove" :file-list="fileContentList" list-type="picture" :limit="1" :on-exceed="scotland" ref="contentStripk">
                        <el-button size="small" type="primary">点击上传</el-button>
                    </el-upload>
                </el-form-item>
                <el-form-item label="活动款式" label-width="80px" prop="product">
                    <el-select v-model="proStyleIdList" multiple :disabled="true" class="special-one">
                        <el-option v-for="item in proStyleList" :key="item.id" :label="item.title" :value="item.id"></el-option>
                    </el-select>
                    <el-button class="styleBtn" size="mini" @click="showStyleListDlog">选择</el-button>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="addDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="addData(addDataForm)">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <!-- 修改 -->
        <el-dialog :title="$t('modify')" :visible.sync="modifyDialogVisible" width="600px" class="addNFRobeDlog" :close-on-click-modal="false" @close="modifyDlogClose(modifyDataForm)">
            <el-form :model="modifyDataForm" :rules="modifyRules" :ref="modifyDataForm" class="motuoForm">
                <el-form-item :label="$t('activityname')" label-width="80px" prop="name">
                    <el-input v-model="modifyDataForm.name" autocomplete="off" clearable :placeholder="$t('plsent')"></el-input>
                </el-form-item>
                <el-form-item label="活动时间" label-width="80px" prop="activityTime">
                    <el-date-picker v-model="modifyDataForm.activityTime" type="daterange" start-placeholder="开始日期" end-placeholder="结束日期" :default-time="['00:00:00', '23:59:59']" value-format="yyyy-MM-dd HH:mm:ss" :picker-options="pickerOptions"></el-date-picker>
                </el-form-item>
                <el-form-item label="banner图" label-width="80px" prop="activityTime">
                    <el-upload class="upload-demo" action="/sys/image/uploadImage" :on-success="handleBannerImgUrl" :on-remove="hadleBannerRemove" :file-list="fileBannerList" list-type="picture" :limit="1" :on-exceed="scotland" ref="bannerStripk">
                        <el-button size="small" type="primary">点击上传</el-button>
                    </el-upload>
                </el-form-item>
                <el-form-item label="内容图片" label-width="80px" prop="activityTime">
                    <el-upload class="upload-demo" action="/sys/image/uploadImage" :on-success="handleContentImgUrl" :on-remove="hadleContentRemove" :file-list="fileContentList" list-type="picture" :limit="1" :on-exceed="scotland" ref="contentStripk">
                        <el-button size="small" type="primary">点击上传</el-button>
                    </el-upload>
                </el-form-item>
                <el-form-item label="活动状态" label-width="80px" prop="activStatus">
                    <el-select v-model="modifyDataForm.activStatus" placeholder="请选择" clearable>
                        <el-option :label="$t('notopened')" :value="0"></el-option>
                        <el-option :label="$t('progresses')" :value="1"></el-option>
                        <el-option :label="$t('over')" :value="2"></el-option>
                    </el-select>
                </el-form-item>
            </el-form>
            <span slot="footer" class="dialog-footer">
                <el-button @click="modifyDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="modifyData(modifyDataForm)">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <!-- 删除 -->
        <el-dialog :title="$t('hint')" :visible.sync="delDialogVisible" width="420px" class="smallDlog" :close-on-click-modal="false">
            <span>{{$t('confirmdel')}}</span>
            <span slot="footer" class="dialog-footer">
                <el-button @click="delDialogVisible = false">{{$t('cancel')}}</el-button>
                <el-button type="primary" @click="delData">{{$t('confirm')}}</el-button>
            </span>
        </el-dialog>
        <!-- 款式列表 -->
        <el-dialog title="款式列表" :visible.sync="styleDialogVisible" width="1200px" class="styleDlog" @close="styleDafultClose">
            <div class="operarea">
                <div class="seach">
                    <el-input v-model="seachStyleForm.styleName" placeholder="风格" clearable size="mini" @keyup.enter.native="seachStyleData"></el-input>
                    <el-input v-model="seachStyleForm.title" placeholder="标题" clearable size="mini" @keyup.enter.native="seachStyleData"></el-input>
                    <el-select v-model="seachStyleForm.publishStatus" placeholder="上下架状态" size="mini" clearable @keyup.enter.native="seachStyleData">
                        <el-option label="上架" :value="2"></el-option>
                        <el-option label="下架" :value="1"></el-option>
                    </el-select>
                    <el-select v-model="seachStyleForm.newStatus" placeholder="新品状态" size="mini" clearable @keyup.enter.native="seachStyleData">
                        <el-option label="非新品" :value="0"></el-option>
                        <el-option label="新品" :value="1"></el-option>
                    </el-select>
                    <el-button size="mini" icon="el-icon-search" @click="seachStyleData"></el-button>
                </div>
            </div>
            <el-card class="cardBox">
                <el-table style="width: 100%" ref="robeTable" :data="styleProTab" stripe row-key="id" @selection-change="handleSelectionChange" @select-all="handleSelectionChange">
                    <el-table-column type="selection" :reserve-selection="true">
                    </el-table-column>
                    <el-table-column prop="itemCode" min-width="131" :label="$t('stylenum')">
                    </el-table-column>
                    <el-table-column prop="title" min-width="131" :label="$t('title')">
                    </el-table-column>
                    <el-table-column prop="styleName" min-width="131" :label="$t('style')">
                    </el-table-column>
                    <el-table-column prop="year" min-width="131" :label="$t('yearofthelisted')">
                    </el-table-column>
                    <el-table-column prop="technology" min-width="131" :label="$t('designprocess')">
                    </el-table-column>
                    <el-table-column prop="publishStatus" min-width="131" label="上下架状态">
                        <template v-slot="scope">
                            <el-tag :type="scope.row.publishStatus === '上架' ? 'success' : 'danger'" :effect="scope.row.publishStatus === '上架' ? 'dark' : 'plain'" size="mini">
                                {{ scope.row.publishStatus }}
                            </el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column prop="newStatus" min-width="131" :label="$t('newpro')">
                        <template v-slot="scope">
                            <el-tag :type="scope.row.newStatus === '新品' ? 'success' : 'danger'" :effect="scope.row.newStatus === '新品' ? 'dark' : 'plain'" size="mini">
                                {{ scope.row.newStatus }}
                            </el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column prop="hotStatus" min-width="131" label="热卖">
                        <template v-slot="scope">
                            <el-tag :type="scope.row.hotStatus === '热卖' ? 'success' : 'danger'" :effect="scope.row.hotStatus === '热卖' ? 'dark' : 'plain'" size="mini">
                                {{ scope.row.hotStatus }}
                            </el-tag>
                        </template>
                    </el-table-column>
                    <el-table-column prop="price" min-width="131" :label="$t('price')">
                    </el-table-column>
                    <el-table-column prop="createTime" min-width="131" :label="$t('addtime')">
                    </el-table-column>
                </el-table>
                <el-pagination
                    small
                    @size-change="handleStyleSizeChange"
                    @current-change="handleStyleCurrentChange"
                    :pager-count="11"
                    :current-page.sync="seachStyleForm.pageNo"
                    :page-sizes="[10, 20, 30, 40]"
                    :page-size="seachStyleForm.pageSize"
                    layout="sizes, prev, pager, next"
                    :total="styleTotal">
                </el-pagination>
            </el-card>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="jayCheck">已选择</el-button>
            </span>
        </el-dialog>
    </div>
</template>

<script>
import {
    getNotPartakeProductItem,
    getActivityList,
    addActivity,
    updateActivityDetail,
    deleteActivDetail
} from '@/libs/reqlist.js'
export default {
    data () {
        return {
            pickerOptions: {
                disabledDate(time) {
                    return time.getTime() < Date.now() - 8.64e7;
                }
            },
            status: '',
            total: 0,
            seachForm: {
                pageNo: 1,
                pageSize: 10,
                name: '',
                type: '',
                activStatus: ''
            },
            festivalTab: [],
            imgList: [],
            // 选中的款式数组
            proStyleList: [],
            proStyleIdList: [],
            //  开启活动
            openDialogVisible: false,
            closeDialogVisible: false,
            // 操作类型
            doType: 0,
            fileBannerList: [],
            fileContentList: [],
            // 添加
            addDialogVisible: false,
            addDataForm: {
                name: '',
                type: '',
                activStatus: 0,
                startTime: '',
                endTime: '',
                bannerUrl: '',
                contentImgUrl: '',
                itemIds: [],
                activityTime: []
            },
            addRules: {
                type: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'change' }
                ],
                name: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ],
                content: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ],
                product: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ],
                activityTime: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'change' }
                ]
            },
            // 修改
            modifyDialogVisible: false,
            modifyDataForm: {
                id: '',
                name: '',
                startTime: '',
                endTime: '',
                bannerUrl: '',
                contentImgUrl: '',
                activStatus: '',
                activityTime: []
            },
            modifyRules: {
                type: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'change' }
                ],
                activityTime: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'blur' }
                ],
                activStatus: [
                    { required: true, message: this.$t('cannotbeemp'), trigger: 'change' }
                ]
            },
            delDialogVisible: false,
            delItemById: '',
            // 款式相关
            styleDialogVisible: false,
            seachStyleForm: {
                pageNo: 1,
                pageSize: 10,
                itemCode: '',
                styleName: '',
                title: '',
                technology: '',
                deleteStatus: '',
                publishStatus: '',
                newStatus: '',
                hotStatus: ''
            },
            styleProTab: [],
            styleTotal: 0,
            selTabData: []
        }
    },
    methods: {
        // 获取数据
        getData () {
            this.seachForm.pageNo = 1
            this.seachData()
        },
        seachData () {
            this.imgList = []
            getActivityList(JSON.stringify(this.seachForm)).then(res => {
                if (res.data.code == 0) {
                    res.data.data.data.forEach(item => {
                        if (item.bannerUrl !== null && item.bannerUrl !== '') this.imgList.push(item.bannerUrl)
                        switch (item.type) {
                            case 0:
                                item.type = '促销'
                                break
                            case 1:
                                item.type = '预售'
                                break
                            case 2:
                                item.type = '其他'
                                break
                        }
                        switch (item.activStatus) {
                            case 0:
                                item.activStatus = '未开启'
                                break
                            case 1:
                                item.activStatus = '进行中'
                                break
                            case 2:
                                item.activStatus = '已结束'
                                break
                        }
                    })
                    this.festivalTab = res.data.data.data
                    this.total = res.data.data.hits
                }
            })
        },
        getSrcList(index) {
            return this.imgList.slice(index).concat(this.imgList.slice(0, index))
        },
        handleSizeChange (newSize) {
            this.seachForm.pageSize = newSize
            this.seachData()
        },
        handleCurrentChange (newNum) {
            this.seachForm.pageNo = newNum
            this.seachData()
        },
        // 图片上传
        scotland() {
            this.$message.warning('只能选择一个文件')
        },
        handleBannerImgUrl(res) {
            if (res.code == 0) {
                switch (this.doType) {
                    case 0:
                        this.addDataForm.bannerUrl = res.data
                        break
                    case 1:
                        this.modifyDataForm.bannerUrl = res.data
                        break
                }
            }
        },
        handleContentImgUrl(res) {
            if (res.code == 0) {
                switch (this.doType) {
                    case 0:
                        this.addDataForm.contentImgUrl = res.data
                        break
                    case 1:
                        this.modifyDataForm.contentImgUrl = res.data
                        break
                }
            }
        },
        hadleBannerRemove(file) {
            if (file) {
                switch (this.doType) {
                    case 0:
                        this.fileBannerList = []
                        this.addDataForm.bannerUrl = ''
                        break
                    case 1:
                        this.fileBannerList = []
                        this.modifyDataForm.bannerUrl = ''
                        break
                }
            }
        },
        hadleContentRemove(file) {
            if (file) {
                switch (this.doType) {
                    case 0:
                        this.fileContentList = []
                        this.addDataForm.contentImgUrl = ''
                        break
                    case 1:
                        this.fileContentList = []
                        this.modifyDataForm.contentImgUrl = ''
                        break
                }
            }
        },
        // 活动状态修改
        editState (data) {
            this.modifyDataForm.id = data.id
            this.modifyDataForm.name = data.name
            this.modifyDataForm.startTime = data.startTime
            this.modifyDataForm.endTime = data.endTime
            if (this.modifyDataForm.startTime) this.modifyDataForm.activityTime.push(this.modifyDataForm.startTime)
            if (this.modifyDataForm.endTime) this.modifyDataForm.activityTime.push(this.modifyDataForm.endTime)
            this.modifyDataForm.activStatus = data.activStatus
            this.modifyDataForm.bannerUrl = data.bannerUrl
            this.modifyDataForm.contentImgUrl = data.contentImgUrl
            if (this.modifyDataForm.bannerUrl !== '' && this.modifyDataForm.bannerUrl !== null) this.fileBannerList.push({ name: this.modifyDataForm.name, url: this.modifyDataForm.bannerUrl })
            if (this.modifyDataForm.contentImgUrl !== '' && this.modifyDataForm.contentImgUrl !== null) this.fileContentList.push({ name: this.modifyDataForm.name, url: this.modifyDataForm.contentImgUrl })
            switch (this.modifyDataForm.activStatus) {
                case '未开启':
                    this.modifyDataForm.activStatus = 1
                    this.openDialogVisible = true
                    break
                case '进行中':
                    this.modifyDataForm.activStatus = 0
                    this.closeDialogVisible = true
                    break
                case '已结束':
                    this.modifyDataForm.activStatus = 2
                    this.$message.error(this.$t('theeventend'))
                    break
            }
        },
        // 活动相关
        activityOpen () {
            updateActivityDetail(JSON.stringify(this.modifyDataForm)).then(res => {
                if (res.data.code == 0) {
                    this.$message({
                        type: 'success',
                        message: this.$t('sucstaoftheact')
                    })
                    this.openDialogVisible = false
                    this.seachData()
                }
            })
        },
        activityClose () {
            updateActivityDetail(JSON.stringify(this.modifyDataForm)).then(res => {
                if (res.data.code == 0) {
                    this.$message({
                        type: 'success',
                        message: this.$t('succonoftheeve')
                    })
                    this.closeDialogVisible = false
                    this.seachData()
                }
            })
        },
        activityDlogClose() {
            this.modifyDataForm.name = ''
            this.modifyDataForm.id = ''
            this.modifyDataForm.startTime = ''
            this.modifyDataForm.endTime = ''
            this.modifyDataForm.bannerUrl = ''
            this.modifyDataForm.contentImgUrl = ''
            this.modifyDataForm.activityTime = []
            this.proStyleList = []
            this.proStyleIdList = []
            this.fileBannerList = []
            this.fileContentList = []
        },
        // 添加
        showAddDlog() {
            this.doType = 0
            this.addDialogVisible = true
        },
        addData() {
            let isPass = false
            if (this.addDataForm.type === '') return this.$message.warning('请选择活动类型')
            if (this.addDataForm.name == '') return this.$message.warning('请填写活动名称')
            if (this.addDataForm.bannerUrl == '') return this.$message.warning('请上传活动banner图')
            if (this.addDataForm.contentImgUrl == '') return this.$message.warning('请上传活动详情图')
            switch (this.addDataForm.activityTime.length) {
                case 0:
                    this.$message.warning('请选择活动时间')
                    isPass = true
                    break
                default:
                    this.addDataForm.startTime = this.addDataForm.activityTime[0]
                    this.addDataForm.endTime = this.addDataForm.activityTime[1]
                    delete this.addDataForm.activityTime
            }
            switch (this.proStyleIdList.length) {
                case 0:
                    this.$message.warning('请选择活动款式')
                    isPass = true
                    break
                default:
                    this.addDataForm.itemIds = this.proStyleIdList
            }
            if (isPass) return
            addActivity(this.addDataForm).then(res => {
                if (res.data.code == 0) {
                    this.$message.success('添加成功')
                    this.addDialogVisible = false
                    this.seachData()
                }
            })
        },
        addDlogClose (form) {
            this.$refs[form].resetFields()
            this.$refs.bannerStripk.clearFiles()
            this.$refs.contentStripk.clearFiles()
            if (this.$refs.robeTable) this.$refs.robeTable.clearSelection()
            this.addDataForm.name = ''
            this.addDataForm.type = ''
            this.addDataForm.startTime = ''
            this.addDataForm.endTime = ''
            this.addDataForm.bannerUrl = ''
            this.addDataForm.contentImgUrl = ''
            this.addDataForm.itemIds = []
            this.addDataForm.activityTime = []
            this.proStyleList = []
            this.proStyleIdList = []
            this.fileBannerList = []
            this.fileContentList = []
        },
        // 修改
        showModify (data) {
            this.modifyDataForm.id = data.id
            this.modifyDataForm.name = data.name
            this.modifyDataForm.startTime = data.startTime
            this.modifyDataForm.endTime = data.endTime
            if (this.modifyDataForm.startTime) this.modifyDataForm.activityTime.push(this.modifyDataForm.startTime)
            if (this.modifyDataForm.endTime) this.modifyDataForm.activityTime.push(this.modifyDataForm.endTime)
            this.modifyDataForm.activStatus = data.activStatus
            switch (this.modifyDataForm.activStatus) {
                case '未开启':
                    this.modifyDataForm.activStatus = 0
                    break
                case '进行中':
                    this.modifyDataForm.activStatus = 1
                    break
                case '已结束':
                    this.modifyDataForm.activStatus = 2
                    break
            }
            this.modifyDataForm.bannerUrl = data.bannerUrl
            this.modifyDataForm.contentImgUrl = data.contentImgUrl
            if (this.modifyDataForm.bannerUrl !== '' && this.modifyDataForm.bannerUrl !== null) this.fileBannerList.push({ name: this.modifyDataForm.name, url: this.modifyDataForm.bannerUrl })
            if (this.modifyDataForm.contentImgUrl !== '' && this.modifyDataForm.contentImgUrl !== null) this.fileContentList.push({ name: this.modifyDataForm.name, url: this.modifyDataForm.contentImgUrl })
            this.modifyDialogVisible = true
        },
        modifyData () {
            let isPass = false
            if (this.modifyDataForm.name == '') return this.$message.warning('请填写活动名称')
            if (this.modifyDataForm.bannerUrl == '') return this.$message.warning('请上传活动banner图')
            if (this.modifyDataForm.contentImgUrl == '') return this.$message.warning('请上传活动详情图')
            switch (this.modifyDataForm.activityTime.length) {
                case 0:
                    this.$message.warning('请选择活动时间')
                    isPass = true
                    break
                default:
                    this.modifyDataForm.startTime = this.modifyDataForm.activityTime[0]
                    this.modifyDataForm.endTime = this.modifyDataForm.activityTime[1]
                    delete this.modifyDataForm.activityTime
            }
            if (isPass) return
            updateActivityDetail(JSON.stringify(this.modifyDataForm)).then(res => {
                if (res.data.code == 0) {
                    this.$message.success('修改成功')
                    this.modifyDialogVisible = false
                    this.seachData()
                }
            })
        },
        modifyDlogClose (form) {
            this.$refs[form].resetFields()
            this.$refs.bannerStripk.clearFiles()
            this.$refs.contentStripk.clearFiles()
            if (this.$refs.robeTable) this.$refs.robeTable.clearSelection()
            this.modifyDataForm.name = ''
            this.modifyDataForm.id = ''
            this.modifyDataForm.startTime = ''
            this.modifyDataForm.endTime = ''
            this.modifyDataForm.bannerUrl = ''
            this.modifyDataForm.contentImgUrl = ''
            this.modifyDataForm.activityTime = []
            this.proStyleList = []
            this.proStyleIdList = []
            this.fileBannerList = []
            this.fileContentList = []
        },
        // 删除
        showDel(id) {
            this.delItemById = id
            this.delDialogVisible = true
        },
        delData () {
            deleteActivDetail(JSON.stringify({ id: this.delItemById })).then(res => {
                if (res.data.code == 0) {
                    this.$message.success('删除成功')
                    this.delDialogVisible = false
                    this.seachData()
                }
            })
        },
        // 款式相关
        showStyleListDlog() {
            this.getStyleData()
            this.styleDialogVisible = true
        },
        getStyleData() {
            getNotPartakeProductItem(JSON.stringify(this.seachStyleForm)).then(res => {
                if (res.data.code == 0) {
                    res.data.data.data.forEach(item => {
                        switch (item.newStatus) {
                            case 0:
                                item.newStatus = '非新品'
                                break
                            case 1:
                                item.newStatus = '新品'
                                break
                        }
                        switch (item.hotStatus) {
                            case 0:
                                item.hotStatus = '非热卖'
                                break
                            case 1:
                                item.hotStatus = '热卖'
                                break
                        }
                        switch (item.publishStatus) {
                            case 0:
                                item.publishStatus = '待上架'
                                break
                            case 1:
                                item.publishStatus = '下架'
                                break
                            case 2:
                                item.publishStatus = '上架'
                                break
                        }
                    })
                    this.styleProTab = res.data.data.data
                    this.styleTotal = res.data.data.hits
                }
            })
        },
        seachStyleData() {
            this.seachStyleData.pageNo = 1
            this.getStyleData()
        },
        handleStyleSizeChange(newSize) {
            this.seachStyleForm.pageSize = newSize
            this.getStyleData()
        },
        handleStyleCurrentChange(newNum) {
            this.seachStyleForm.pageNo = newNum
            this.getStyleData()
        },
        styleDafultClose() {
            this.seachStyleForm.pageNo = 1
            this.seachStyleForm.styleName = ''
            this.seachStyleForm.title = ''
            this.seachStyleForm.publishStatus = ''
            this.seachStyleForm.newStatus = ''
        },
        handleSelectionChange(select) {
            this.selTabData = select
        },
        jayCheck() {
            this.proStyleList = []
            this.proStyleIdList = []
            this.selTabData.forEach(item => {
                this.proStyleList.push(item)
                this.proStyleIdList.push(item.id)
            })
            this.styleDialogVisible = false
        }
    },
    mounted() {
        this.seachData()
    }
}
</script>

<style lang="less" scoped>
@import './festival.less';
</style>
